/**
 * UploadResponse.java
 */
package fss.common.communication;

import fss.transfer.TransferId;
import fss.util.rmi.RmiId;

/**
 * An upload response is used by the File Service indicating that
 * the service is ready for upload. The client who processes this
 * response must initialize the upload.
 * 
 * @author thinh
 *
 */
public class UploadResponse extends Response {
    private static final long serialVersionUID = 1L;
    /**
     * The transfer identifier.
     */
    private TransferId transferId = null;
    /**
     * The offset of the last downloaded data.
     */
    private long offset = 0;
    /**
     * Create an upload response for the specified transfer identifier.
     * @param the creator of this message.
     * @param transferId the transfer identifier.
     */
    public UploadResponse(RmiId sourceId, TransferId transferId) {
        super(sourceId, transferId.getDestinationId());
        this.transferId = transferId;
    }
    /**
     * Get the transfer identifier.
     * @return the transfer identifier.
     */
    public TransferId getTransferId() {
        return transferId;
    }
    /**
     * Set the transfer identifier. 
     * @param transferId the identifier.
     */
    public void setTransferId(TransferId transferId) {
        this.transferId = transferId;
    }
    /**
     * The offset of the the last uplaoded byte position.
     * <p>
     * If the offset is zero, then it indicates a new upload transfer.
     * @return the offset.
     */
    public long getOffset() {
        return offset;
    }
    /**
     * Set the offset.
     * @param offset the offset byte position.
     */
    public void setOffset(long offset) {
        this.offset = offset;
    }
}
